# match和 search:
# 1.只对字符串查找一次  2.返回re.Match object
# 1.match从头匹配，search全字符串匹配
# finditer:查找所有的匹配数据
# findall:将所有匹配数据放到列表中
# fullmatch:Try to apply the pattern to all of the string
import re

s1 = 'qwe,abc1,abc,asd,abc2,ljk,abc,abc,abc'
print(re.match('qwe', s1))  # <re.Match object; span=(0, 3), match='qwe'>
print(re.search('qwe', s1))  # <re.Match object; span=(0, 3), match='qwe'>
print(re.match('abc', s1))  # None
print(re.search('abc', s1))  # <re.Match object; span=(4, 7), match='abc'>

f_i = re.finditer('abc', s1)
print(f_i)  # <callable_iterator object at 0x0000022FF3782B48>
for o in f_i:  # o 是 re.Match object
    print(o)  # <re.Match object; span=(4, 7), match='abc'>...........

print(re.findall('abc', s1))  # ['abc', 'abc', 'abc', 'abc', 'abc', 'abc']
print(re.findall(r'abc\d+', s1))  # ['abc1', 'abc2']

s2 = 'hello, world'
s3 = 'hlffnlsfsfsbffd'
print(re.fullmatch('h.*d', s2))  # <re.Match object; span=(0, 12), match='hello, world'>
print(re.fullmatch('h.*d', s3))  # <re.Match object; span=(0, 15), match='hlffnlsfsfsbffd'>
